<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    // 检查用户是否已登录
    String username = (String) session.getAttribute("username");
    if (username == null) {
        // 如果未登录，重定向到登录页面
        response.sendRedirect("login.jsp");
        return;
    }
    java.util.Date loginTime = (java.util.Date) session.getAttribute("loginTime");
%>
<html>
<head>
    <title>欢迎页面</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <style>
        .welcome-container {
            max-width: 600px;
            margin: 100px auto;
            padding: 20px;
            border-radius: 10px;
            box-shadow: 0 0 10px rgba(0,0,0,0.1);
        }
        .user-info {
            margin: 20px 0;
            padding: 15px;
            background-color: #f8f9fa;
            border-radius: 5px;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="welcome-container">
            <h2 class="text-center mb-4">欢迎回来，<%= username %>！</h2>
            <div class="user-info">
                <p><strong>用户名：</strong><%= username %></p>
                <p><strong>登录时间：</strong><%= loginTime %></p>
            </div>
            <div class="text-center">
                <a href="calculator.jsp" class="btn btn-primary me-2">使用计算器</a>
                <a href="logout.jsp" class="btn btn-danger">注销</a>
            </div>
        </div>
    </div>
</body>
</html>